import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  OneToMany,
} from 'typeorm';
import { Goods } from './Goods';

@Entity()
export class Menu {
  @PrimaryGeneratedColumn()
  id: number;

  /**
   * 菜单名
   */
  @Column({ length: 50 })
  name: string;

  /**
   * 商品列表
   * 定义表关系, @OneToMany不可以单独出现，对应的Car实体中必须存在对应的@ManyToOne修饰的属性person
   */
  @OneToMany(() => Goods, (goods) => goods.menu)
  goods: Goods[];

  @Column({ default: 0 })
  sort: number;

  @Column({ default: false })
  delete: boolean;

  @CreateDateColumn()
  created: Date;

  @UpdateDateColumn()
  updated: Date;
}
